import request from '@/utils/request'
import type { ApiResponse } from './components/ApiResponse'
import type {
  CategoryType,
  CategoryByIdType,
  CategoryTwoByIdType,
  PostMoreGoodsType,
  MoreGoodsType,
} from './components/categoryType'

// 获取全部分类(包括推荐商品)
export const getAllCategoryListApi = () => {
  return request.get<ApiResponse<[CategoryType]>>('/home/category/head')
}

// 根据ID获取一级分类信息
export const getCategoryByIdApi = (id: string) => {
  return request.get<ApiResponse<CategoryByIdType>>('/category', {
    params: { id },
  })
}

// 根据ID获取二级分类信息
export const getCategoryChildrenByIdApi = (id: string) => {
  return request.get<ApiResponse<CategoryTwoByIdType>>('/category/sub/filter', {
    params: { id },
  })
}

// 获取更多商品数据
export const getMoreCategoryApi = (data: PostMoreGoodsType) => {
  return request.post<ApiResponse<MoreGoodsType>>('/category/goods/temporary', data)
}
